home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16.lha / Python-1.6 / Lib / Python1.6 / distutils / command / install_scripts.py < prev    next >
Encoding:
Python Source  |  2000-05-27  |  1.9 KB  |  58 lines

  1. """distutils.command.install_scripts
  2.  
  3. Implements the Distutils 'install_scripts' command, for installing
  4. Python scripts."""
  5.  
  6. # contributed by Bastian Kleineidam
  7.  
  8. __revision__ = "$Id: install_scripts.py,v 1.7 2000/05/27 17:27:23 gward Exp $"
  9.  
  10. import os
  11. from distutils.core import Command
  12. from stat import ST_MODE
  13.  
  14. class install_scripts (Command):
  15.  
  16.     description = "install scripts (Python or otherwise)"
  17.  
  18.     user_options = [
  19.         ('install-dir=', 'd', "directory to install scripts to"),
  20.         ('build-dir=','b', "build directory (where to install from)"),
  21.         ('skip-build', None, "skip the build steps"),
  22.     ]
  23.  
  24.     def initialize_options (self):
  25.         self.install_dir = None
  26.         self.build_dir = None
  27.         self.skip_build = None
  28.  
  29.     def finalize_options (self):
  30.         self.set_undefined_options('build', ('build_scripts', 'build_dir'))
  31.         self.set_undefined_options ('install',
  32.                                     ('install_scripts', 'install_dir'),
  33.                                     ('skip_build', 'skip_build'),
  34.                                    )
  35.  
  36.     def run (self):
  37.         if not self.skip_build:
  38.             self.run_command('build_scripts')
  39.         self.outfiles = self.copy_tree (self.build_dir, self.install_dir)
  40.         if os.name == 'posix':
  41.             # Set the executable bits (owner, group, and world) on
  42.             # all the scripts we just installed.
  43.             for file in self.get_outputs():
  44.                 if self.dry_run:
  45.                     self.announce("changing mode of %s" % file)
  46.                 else:
  47.                     mode = (os.stat(file)[ST_MODE]) | 0111
  48.                     self.announce("changing mode of %s to %o" % (file, mode))
  49.                     os.chmod(file, mode)
  50.  
  51.     def get_inputs (self):
  52.         return self.distribution.scripts or []
  53.  
  54.     def get_outputs(self):
  55.         return self.outfiles or []
  56.  
  57. # class install_scripts
  58.